package mylib.dir;

import java.util.Set;
import java.util.TreeMap;

/**
 * Created with IntelliJ IDEA.
 * User: 1
 * Date: 20.07.12
 * Time: 15:55
 * To change this template use File | Settings | File Templates.
 */
public class Counter32<K extends Comparable<K>> {
    private TreeMap<K, Integer> data;

    public Counter32() {
        data = new TreeMap<K, Integer>();
    }

    public int get(K key) {
        Integer r = data.get(key);
        if (r == null)
            return 0;
        return r;
    }

    public void add(K key, int by) {
        data.put(key, get(key) + by);
    }

    public Set<java.util.Map.Entry<K, Integer>> getEntrySet() {
        return data.entrySet();
    }
}
